<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        div {
            width: 500px;
            height: 500px;
            background-color: skyblue;
            margin: 30px;
            overflow: hidden;
        }

        p {
            width: 300px;
            height: 300px;
            background-color: orange;
            margin: 30px;
            overflow: hidden;
        }

        span {
            display: block;
            width: 100px;
            height: 100px;
            background-color: pink;
            margin: 30px;
            border: 10px solid red;
        }


        ul {
            width: 300px;
            height: 300px;
            padding: 30px;
            border: 30px solid #333;
            background-color: skyblue;
            background-clip: content-box;

            border-top-width: 50px;
            border-left-width: 100px;
        }
    </style>
</head>

<body>
    <div>
        <p>
            <span></span>
        </p>
    </div>


    <ul></ul>

    <script>
        var spanEle = document.querySelector('span');
        //offsetParent 就是它的定位父级
        console.log('定位父级',spanEle.offsetParent);//body


        // console.log('偏移量左',spanEle.offsetLeft);
        // // span 外边距30+ｐ外边距３０＋ｄｉｖ　外边距３０　　ｂｏｄｙ
        // console.log('偏移量上',spanEle.offsetTop);
        // //  span 外边距30+ｐ外边距３０＋ｄｉｖ　外边距３０　　ｂｏｄｙ

        console.log('client左',spanEle.clientLeft); // 10
        console.log('client上',spanEle.clientTop); // 10

        // 简单来说就是上边框和左边框的大小  
    </script>


</body>
</html>